D:\git\skunkworks\herald-for-cpp\herald-tests\uint32-tests.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2021 Herald Project Contributors |
2 | | // SPDX-License-Identifier: Apache-2.0 |
3 | | // |
4 | | |
5 | | #include <iostream> |
6 | | #include <fstream> |
7 | | #include <string> |
8 | | |
9 | | #include "catch.hpp" |
10 | | |
11 | | #include "herald/herald.h" |
12 | | |
13 | | #include "test-util.h" |
14 | | |
15 | 0 | TEST_CASE("crossplatform-uint32", "[.][uint32][crossplatform]") { |
16 | 0 | SECTION("crossplatform-uint32") { |
17 | 0 | // Check output file can be created |
18 | 0 | auto fn = testutil::fullFilename("uint32.csv"); |
19 | 0 | INFO("Output filename: " << fn); |
20 | 0 | std::ofstream cppOut(fn); |
21 | 0 | cppOut << "value,data" << std::endl; |
22 | 0 | std::uint32_t result; |
23 | 0 | std::uint32_t i(1); |
24 | 0 | std::uint32_t max(std::numeric_limits<uint32_t>::max() / 7); |
25 | 0 | while (i <= max) { |
26 | 0 | herald::datatype::Data data; |
27 | 0 | data.append(i); |
28 | 0 | cppOut << (unsigned long)i << "," << herald::datatype::Base64String::encode(data).encoded() << std::endl; |
29 | 0 | i *= 7; |
30 | 0 | } |
31 | 0 |
|
32 | 0 | cppOut.close(); |
33 | 0 |
|
34 | 0 | // Now ensure our output matches the other platforms' |
35 | 0 | testutil::validateEqual("uint32.csv"); |
36 | 0 | } |
37 | 0 | } |